# 作者: 宇
# 2025年02月21日17时42分27秒

class Person:
    def __init__(self,name,age,weight):
        self.name=name
        self.age=age
        self.weight=weight

    def run(self):
        self.weight-=0.5
        print(f"{self.name}跑步了,体重减少了0.5公斤{self.weight}")
    def eat(self):
        self.weight+=1
        print(f"{self.name}吃东西了,体重增加了1公斤{self.weight}")

    def __str__(self):
        return f"{self.name}现在体重是{self.weight}"



# ele=Person('大象',18,80)
# ele.run()
# ele.eat()
# print(ele)

class HouseItem:
    def __init__(self,name,area):
        self.name=name
        self.area=area

    def __str__(self):
        return f"{self.name}占地{self.area}平方"

class House:
    def __init__(self,house_type,area):
        self.house_type=house_type
        self.area=area
        self.free_area=area
        self.item_list=[]

    def add_item(self,item:HouseItem):#冒号：类名是注解的作用
        print(f"要添加{item}")
        if self.free_area>=item.area:
            self.item_list.append(item.name)
            self.free_area-=item.area
        else:
            print("空间不足")

    def __str__(self):
        return ("户型:%s\n总面积%.2f[剩余:%.2f]\n家具:%s"
                %(self.house_type,self.area,self.free_area,self.item_list))

bed=HouseItem("席梦思",4)
chest=HouseItem("衣柜",2)
table=HouseItem("桌子",1.5)
TOOL=HouseItem("大型工具",70)
#
# print(bed)
# print(chest)
# print(table)

house=House('三室一厅',80)
print(house)
house.add_item(bed)
house.add_item(chest)
house.add_item(table)
house.add_item(TOOL)
print(house)
